package cn.glutnn.utils;

import java.util.Map;

/**
 * ThreadLocal工具类，用于在线程间传递用户数据
 * @author msh
 * @date 2025/04/04
 */
public class ThreadLocalUtil {
    private static final ThreadLocal<Map<String, Object>> THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 设置线程变量
     * @param map 变量值
     */
    public static void set(Map<String, Object> map) {
        THREAD_LOCAL.set(map);
    }

    /**
     * 获取线程变量
     * @return 变量值
     */
    public static Map<String, Object> get() {
        return THREAD_LOCAL.get();
    }

    /**
     * 移除线程变量
     */
    public static void remove() {
        THREAD_LOCAL.remove();
    }
} 